<template>
  <div class="users">
    <h1>Hello Users</h1>
    <ul>
        <li v-for="(user,index) in users" :key="index">
            <h2>{{user.name}}</h2>
            <h3>{{user.email}}</h3>
        </li>
    </ul>

    <button @click="deleteUser">删除</button>
  </div>
</template>

<script>
export default {
  name: 'users',
  //获取父组件的传值，名字为自定属性名
  //props:["users"],
  //标准写法
  props:{
    users:{
      type:Array,//数据类型
      required:true//是否必要的
    }
  },
  data(){
      return{
      }
  },
  methods:{
    deleteUser:function(){
      this.users.pop();
    }
  }
}
</script>

<style scoped>
.users{
  width: 100%;
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
  box-sizing: border-box;
}
ul{
  display: flex;
  flex-wrap: wrap;
  list-style-type: none;
  padding: 0;
}
li{
  /* 一行只有一个，一个撑满整行 */
  flex-grow: 1;
  flex-basis: 200px;
  text-align: center;
  padding: 30px;
  border: 1px solid #222;
  margin: 10px;
}
</style>
